home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / RGASM.RAR / ASMCODE.EXE / CHAPT1-5 / OUTDEC.ASM < prev    next >
Encoding:
Assembly Source File  |  1993-05-10  |  1.4 KB  |  27 lines

  1. ;
  2. ;       Program OutDec
  3. ;
  4. .model  small                   ; small memory model - one segment only
  5. .stack                          ; stack of default size
  6. .data                           ; this starts data segment
  7. UnsWord dw      1993            ; number to be output
  8. Ten     dw      10              ; constant for obtaining decimal digits
  9. .code                           ; this starts code segments
  10. .startup                        ; this initializes segment registers
  11.     mov     ax,UnsWord      ; place number to be printed into AX.
  12.     mov     cx,0            ; clear counter of digits 
  13. NexDiv: mov     dx,0            ; clear high part of number
  14.     div     Ten             ; divide number to be prinred by 10
  15.     push    dx              ; push remainder (current digit) into stack.
  16.     inc     cx              ; increase counter of digits
  17.     cmp     ax,0            ; result is zero? (number was less than 10)
  18.     jne     NexDiv          ; if not, continue process (get next digit)
  19.     mov     ax,0200h        ; function 02h - output character
  20. OutSym: pop     dx              ; pop current digit from stack
  21.     add     dl,30h          ; convert digit to character
  22.     int     21h             ; DOS service call
  23.     loop    OutSym          ; to output next digit
  24. FinProg:mov     ax,4C00h        ; function 4Ch - terminate process (exit code 0)
  25.     int     21h             ; DOS service call
  26.     end     
  27.